﻿@using System.Web.UI.WebControls
@using QBWeb.ViewModels
@{
    ViewBag.Title = "详情";
    Layout = "~/Views/Shared/_Layout.cshtml";
    var count = 0;
    var name = ViewBag.name;
    var id = ViewBag.id;
}

<h3 data-name="@name" data-test="@id" id="headTop">@name</h3>
<div style="float:right;margin-bottom:10px;">
    <button type="button" onclick="goOut()" class="btn btn-default">返回</button>
</div>
<table class="layui-table">
    <thead>
    <tr>
        <th>
            题目ID
        </th>
        <th>
            题干
        </th>
        <th>
            所选(填)答案
        </th>
        <th>
            对错
        </th>
    </tr>
    </thead>
    @foreach (var item in (List<AnswerInfoQuest>)ViewBag.data2)
    {
        count++;
        <tr>
            <td>@count</td>
            <td>@item.QuestionTb.QuestName</td>
            <td>@item.AnswerInfoTb.Answer</td>
            <td>
                @if (item.AnswerInfoTb.TF == 1)
                {
                    <span>对</span>
                }
                else
                {
                    <span>错</span>
                }
            </td>
        </tr>
    }
</table>
<p style="text-align: center">
    @Html.DropDownList("status",new List<SelectListItem>()
    {
        new SelectListItem{Text = "未审阅",Value = "0",Selected = true},
        new SelectListItem{Text = "已审阅",Value = "1"}
    },htmlAttributes:new{@class="form-control",onchange="SubmitStatus()",style="width: 100px"})
</p>
<script type="text/javascript">
    var name = $("#headTop").data("name");
    var id = $("#headTop").data("test");

    function SubmitStatus() {
        var index = $("#status").find("option:selected").val();
        $.ajax({
            type: "POST",
            url: "/AnswerInfoTb/EditStatus",
            data: {
                testId: id,
                stuName: name,
                status: index
            },
            dataType: 'json',
            success: function () {
                layer.msg("审阅成功");
            }, error: function (data) {
                layer.msg("审阅失败");
            }
        });
    }
    function goOut() {
        history.go(-1);
    }
</script>